import {
  TokenRequestData,
  TableResponseData,
  ProductDataType,
  ProductType,
  BindAndReturnAddressType,
  feeRulesType,
  returnLocationType
} from '@/types/interface'
import {
  OnlineStatus,
  LockStatus,
  AllowChangeBattery,
  VoltageType,
  FeeRulesType,
  LongBikeState,
  TimeBikeState,
  BikeType,
  isHasMask,
  MaskStatusType,
  isHasBattery,
  LuggageStatus,
  AssistReturnBikeType,
  ShowReturnLocationType
} from '@/types/enum'
import { StoreTableCol } from '@/api/store/types/store'
import { bikeShortTermDetailOrderTableCol } from '@/api/user/types/user'
import { StoreInfoType } from '@/api/order/types/order'
import { stepDataEntity } from '@/api/operation/types/operation'
/** 长租车  */
export interface queryBikeRequestData extends TokenRequestData {
  bikeCode: string
  type: LongBikeState
  storeId: string
  pageNum?: number
  pageSize?: number
}
/**
 * @param bikeId: 后端查询车辆编号所需
 * @param bikeCode: 前端展示的车辆编号
 *
 */
export interface queryBikeTableCol {
  bikeId: string
  bikeCode: string
  bikeLockId: string
  bikeName: string
  powerLevel: string
  longtitude: number | null
  latitude: number | null
  bikeOnlineStatus: OnlineStatus
  lockStatus: null | LockStatus
  smartKey: null | string
  storeId: string
  contactPhone: string | null
  /** 租用中则不为null */
  userId: string | null
  orderId: string | null
  usedTime: string | null
  startTime: string | null
  product: ProductType[] | null
  /** 订单结束则为null */
  productData: ProductDataType | null
  bikeStatus: string
  inputVoltage: string
  bikeModel: string
  carNumber: string
  storeData: StoreTableCol | {}
  frameNumber: string
  bindAddress: BindAndReturnAddressType | null
  returnAddress: BindAndReturnAddressType | null
}
export type queryBikeResponseData = TableResponseData<queryBikeTableCol>

export type queryBikeResponse = ApiResponseData<queryBikeResponseData>

/**故障记录  */
export interface queryBikeCheckRequestData extends TokenRequestData {
  bikeId: string
  bikeCode: string
  startTime: string
  endTime: string
}
export enum stateType {
  Nomal,
  Err
}
export interface resultDetailsType {
  name: string
  state: stateType
  /** 部件检测描述 */
  description: string
}
export interface queryBikeCheckCol {
  bikeCheckId: string
  bikeId: string
  result: string
  createdTime: string
  updatedTime: string
  resultDetails: resultDetailsType[]
  errCount: number | string
  channel: string
}
export type queryBikeCheckResponseData = TableResponseData<queryBikeCheckCol>

export type queryBikeCheckResponse = ApiResponseData<queryBikeCheckResponseData>

/** 租赁记录 */
export interface queryBikeRentRecordRequestData extends TokenRequestData {
  bikeId: string
  bikeCode: string
  startTime: string
  endTime: string
}
export interface queryBikeRentRecordCol {
  bikeId: string
  rentUser: string
  rentPeriod: string
  startTime: string
  endTime: string
}
export type queryBikeRentRecordResponseData = TableResponseData<queryBikeRentRecordCol>

export type queryBikeRentRecordResponse = ApiResponseData<queryBikeRentRecordResponseData>

/** 获取车辆轨迹日期列表  */

export interface queryBikeTrackDateRequestData extends TokenRequestData {
  bikeId: string
}

export type queryBikeTrackDateResponse = ApiResponseData<string[]>

/** 获取车辆行驶轨迹 */
export interface queryBikeTrackRequestData extends TokenRequestData {
  bikeId: string
  startTime: string
}

export interface bikeGPSListType {
  longtitude: string
  latitude: string
  recordTime: string
  distance?: number
  time?: string
  address?: string
}
export enum tripStatusType {
  First,
  Mid,
  Last
}
export interface queryBikeTrackResponseData {
  bikeLockId: string
  unlockTime: string
  unlockLongtitude: string
  unlockLatitude: string
  lockTime: string
  lockLongtitude: string
  lockLatitude: string
  step: boolean
  tripStatus: tripStatusType
  tripDays: string[]
  bikeGPSList: bikeGPSListType[][]
}
export type queryBikeTrackResponse = ApiResponseData<queryBikeTrackResponseData[]>
/** -------------------------------短租车-------------------------------- */
/**
 * @description 获取短租车列表
 * @param type - 为门店详情的查询参数 在短租车列表固定为0
 */
export interface queryShortBikeRequestData extends TokenRequestData {
  bikeCode?: string
  storeId?: string
  bikeStatus?: TimeBikeState
  lockStatus?: LockStatus | ''
  onlineStatus?: OnlineStatus | ''
  voltage?: VoltageType | ''
  allowChangeBattery?: AllowChangeBattery | ''
  feeRule?: FeeRulesType | ''
  minPower?: number
  maxPower?: number
  type?: BikeType
}
export interface batterySizeType {
  batterySizesId: string
  name: string
  imageUrl: string
  brand: string
  volt: string
  current: string
  remark: string
}
export interface queryShortBikeCol {
  bikeId: string
  bikeCode: string
  lockId: string
  orderId: string | null
  phone: string | null
  startTime: string | null
  usedTime: string | null
  bikeStatus: string
  lockStatus: null | LockStatus
  bikeOnlineStatus: OnlineStatus
  powerLevel: string
  bikeName: string
  inputVoltage: string
  frameNumber: string
  carNumber: string
  allowChangeBattery: AllowChangeBattery
  longtitude: string | number
  latitude: string | number
  storeData: StoreTableCol | {}
  batterySize: batterySizeType[]
  productType: FeeRulesType
  feeRules: feeRulesType[]
  hasMask: isHasMask
  maskStatus: MaskStatusType
  hasBattery: isHasBattery
  luggageStatus: LuggageStatus
  userId?: string
  rentCardName?: string
}
export type queryShortBikeResponseData = TableResponseData<queryShortBikeCol>

export type queryShortBikeResponse = ApiResponseData<queryShortBikeResponseData>

export interface queryBikeShortTermTrackRequestData extends TokenRequestData {
  bikeId: string
  orderId: string
  storeId?: string
}
export interface queryBikeShortTermTrackResponseData {
  bikeId: string //车辆ID
  startTime: string //开始时间
  endTime: string //结束时间
  startLongitude: string //开始经度
  startLatitude: string //开始纬度
  endLongitude: string
  endLatitude: string
  bikeGpsList: bikeGPSListType[] | null
  coordinates: coordinatesType[]
  returnLocations: returnLocationType[]
}
export type queryBikeShortTermTrackResponse = ApiResponseData<queryBikeShortTermTrackResponseData>

export interface queryShortTermBikeLocationRequestData extends TokenRequestData {
  bikeId?: string
  storeId?: string
  showReturnLocation: ShowReturnLocationType
}
export interface coordinatesType {
  number: number
  longtitude: number
  latitude: number
}
export interface bikeLocationDataType {
  bikeId: string //车辆ID
  bikeCode: string //车辆编号
  longtitude: number
  latitude: number
  lockStatus: LockStatus
  bikeOnlineStatus: OnlineStatus
  powerLevel: string
  inputVoltage: string
  plateNumber: string
  lastReturnTime: string
  bikeStatus: string
}
export interface queryShortTermBikeLocationResponseData {
  bikeLocationData: bikeLocationDataType[]
  returnLocation: returnLocationType[]
  coordinates: coordinatesType[]
}

export type queryShortTermBikeLocationResponse =
  ApiResponseData<queryShortTermBikeLocationResponseData>

/** 短租车常规还车 */
export interface assistReturnBikeRequestData extends TokenRequestData {
  bikeId: string
  type: AssistReturnBikeType
}

export type assistReturnBikeResponse = ApiResponseData<string>

/** 短租车强制还车 */
export interface forceReturnBikeRequestData extends TokenRequestData {
  bikeId: string
}
export type forceReturnBikeResponse = ApiResponseData<string>
/** 短租车历史行程 */
export interface queryTimeBikeHistoryLocusRequestData extends TokenRequestData {
  phone?: string
  bikeCode?: string
  startTime?: string
  endTime?: string
  pageNum?: number
  pageSize?: number
}
export type queryTimeBikeHistoryLocusTabelCol = bikeShortTermDetailOrderTableCol

export type queryTimeBikeHistoryLocusTabelResponseData =
  TableResponseData<queryTimeBikeHistoryLocusTabelCol>

export type queryTimeBikeHistoryLocusTabelResponse =
  ApiResponseData<queryTimeBikeHistoryLocusTabelResponseData>

/** 短租车辆关锁 */
export interface lockShortTermBikeRequestData extends TokenRequestData {
  bikeId: string
}
export type lockShortTermBikeResponse = ApiResponseData<string>
/** 短租车辆解除维修 */
export interface unMaintenanceShortTermBikeRequestData extends TokenRequestData {
  bikeId: string
}
export type unMaintenanceShortTermBikeResponse = ApiResponseData<string>
/** 短租车辆解除维修 */
export interface MaintenanceShortTermBikeRequestData extends TokenRequestData {
  bikeId: string
}
export type MaintenanceShortTermBikeResponse = ApiResponseData<string>
/** 车辆信息 */
export interface BikeInfoResponseData {
  storeData: StoreInfoType
  feeRules: feeRulesType[]
  batterySize: batterySizeType[]
  bikeId: string
  bikeCode: string
  bikeLockId: string
  imageUrls: string
  bikeModel: string
  productImageUrls: string
  productType: FeeRulesType
  frameNumber: string
  batterySizeDescription: string
}
export type BikeInfoResponse = ApiResponseData<BikeInfoResponseData>
export interface BikeInfoRequestData extends TokenRequestData {
  bikeId: string
}

/** 发送命令刷新短租车位置 */
export type refreshShortTermBikeLocationResponse = ApiResponseData<string>
export interface refreshShortTermBikeLocationRequestData extends TokenRequestData {
  bikeId: string
}

/** 增加备注 */
export interface addRemarkRequestData extends TokenRequestData {
  orderId: string
  content: string
}
export type addRemarkResponse = ApiResponseData<string>
/** 查看备注 */
export interface queryOrderRemarkRequestData extends TokenRequestData {
  orderId: string
}
export type queryOrderRemarkResponse = ApiResponseData<stepDataEntity[]>

/** 查看车辆附近还车点 */
export interface queryShortTermRangeRequestData extends TokenRequestData {
  bikeCode: string
}

export interface queryShortTermRangeResponseData {
  returnLocation: returnLocationType[]
  coordinates: coordinatesType[]
}

export type queryShortTermRangeResponse = ApiResponseData<queryShortTermRangeResponseData>

/** 开头盔锁 */
export interface openMaskRequestData extends TokenRequestData {
  bikeId: string
}
export type openMaskResponse = ApiResponseData<string>
